export default function myAsync(fn){
    return function(){
        try{
            return Promise.resolve( fn(...arguments) )
        }catch(e){
            return Promise.reject(e)
        }
    }
}

async function test(){
    function test_resolve(x){
        return x+1
    }
    let async_resolve = myAsync(test_resolve)
    console.log(await async_resolve(1))
    function test_reject(x){
        throw x+1
    }
    let async_reject = myAsync(test_reject)
    async_reject(1).catch(e=>{
        console.log(e)
    })
}
